Socket
Socket
Sign inDemoInstall

@gitbeaker/requester-utils

Package Overview
Dependencies
22
Maintainers
1
Versions
246
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @gitbeaker/requester-utils

Utility functions for requester implementatons used in @gitbeaker


Version published
Weekly downloads
659K
decreased by-3.72%
Maintainers
1
Install size
852 kB
Created
Weekly downloads
 

Package description

What is @gitbeaker/requester-utils?

@gitbeaker/requester-utils is a utility package designed to facilitate HTTP requests, particularly in the context of interacting with GitLab's API. It provides a set of tools to simplify the process of making authenticated requests, handling responses, and managing configurations.

What are @gitbeaker/requester-utils's main functionalities?

Authenticated Requests

This feature allows you to create a requester function that automatically includes authentication headers in your HTTP requests. The code sample demonstrates how to create a requester and make a GET request to fetch projects.

const { createRequesterFn } = require('@gitbeaker/requester-utils');

const requester = createRequesterFn({
  host: 'https://gitlab.example.com',
  token: 'your_access_token',
});

requester.get('/projects')
  .then(response => console.log(response))
  .catch(error => console.error(error));

Custom Request Configurations

This feature allows you to customize various request configurations such as timeout settings. The code sample shows how to set a custom request timeout.

const { createRequesterFn } = require('@gitbeaker/requester-utils');

const requester = createRequesterFn({
  host: 'https://gitlab.example.com',
  token: 'your_access_token',
  requestTimeout: 5000,
});

requester.get('/projects')
  .then(response => console.log(response))
  .catch(error => console.error(error));

Handling Responses

This feature provides a way to handle responses and errors effectively. The code sample demonstrates how to check the response status and handle errors.

const { createRequesterFn } = require('@gitbeaker/requester-utils');

const requester = createRequesterFn({
  host: 'https://gitlab.example.com',
  token: 'your_access_token',
});

requester.get('/projects')
  .then(response => {
    if (response.status === 200) {
      console.log('Projects:', response.data);
    } else {
      console.error('Error:', response.statusText);
    }
  })
  .catch(error => console.error('Request failed:', error));

Other packages similar to @gitbeaker/requester-utils

Readme

Source

gitbeaker

CircleCI Pipeline Status Code Climate maintainability CodeCov test coverage Dependency Status Dev Dependency Status Auto All Contributors Prettier Licence: MIT Install Size: Requester Utils

A Utility library for creating custom requesters for @gitbeaker to use

Read More

Keywords

FAQs

Last updated on 14 Mar 2023

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc